import redis

db_config = {
    'host': '118.24.27.37',
    'db': 5,
    'charset': 'utf8'
}


class RedisList:
    def __init__(self):
        self.conn = redis.StrictRedis(**db_config)

    def push(self, key, d='r', *values):
        if d == 'l':
            self.conn.lpush(key, *values)

        elif d == 'r':
            self.conn.lpush(key, *values)

    def get(self, key, start_index, end_index):
        return self.conn.lrange(key, start_index, end_index)

    def set(self, key, index, value):
        self.conn.lset(key, index, value)

    def pop(self, key, count, value, d = 'r'):# 删除
        if d == 'r':
            self.conn.lpop(key)# 左删除
        elif d == 'l':
            self.conn.rpop(key)
        else:
            self.conn.lrem(key, count, value)

if __name__ == '__main__':
    rlist = RedisList()
    # rlist.push('name', 'r', 'lt1', 'lt2', 'lt3')
    print(rlist.get('name',0,-1))
